package 网络编程.udp协议通信;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.util.Scanner;
public class 客户端 {
    public static void main(String[] args) throws Exception {
        DatagramSocket socket = new DatagramSocket(9999);
        Scanner sc = new Scanner(System.in);
        while (true) {
            var s = sc.nextLine();
            byte[] data = s.getBytes();
            DatagramPacket packet = new DatagramPacket(data, data.length, InetAddress.getLocalHost(), 9999);
            socket.send(packet);
            if (s.equals("再见"))
                break;
        }
        socket.close();

    }
}
